{% extends 'index.html' %}
{% block page-content %}
<div id="page-wrapper">
    <div class="row">
         <div class="col-lg-12">
              <h1 class="page-header"><i class="fa  fa-print  "></i> 项目部署操作日志</h1>
         </div>
                <!-- /.col-lg-12 -->
    </div>
	<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           	<i class="fa   fa-gear"></i> 操作日志
                        </div>
                        <div class="panel-body">

				                            
				           <ul class="nav nav-tabs">
				              <li class="active"><a href="#profile" data-toggle="tab"><i class="fa  fa-github-alt"></i> 项目操作日志</a>
				              </li>			              
				           </ul>
				
				                            
				           <div class="tab-content">
				              <div class="tab-pane fade in active" id="profile">
				                   <div class="row">
				                   		<div class="col-lg-12">
				                   			<br>
				                            <table width="100%" class="table table-striped table-bordered table-hover" id="projectTableList">
				                                <thead>
				                                    <tr>
				                                    	<th class="text-center">产品线</th>
				                                    	<th class="text-center">项目名称</th>
				                                    	<th class="text-center">项目环境</th>
				                                    	<th class="text-center">版本号</th>
				                                    	<th class="text-center">操作内容</th>
				                                    	<th class="text-center">操作用户</th>
														<th class="text-center">操作时间</th>
				                                        {% if perms.OpsManage.delete_log_project_config %}
				                                        	<th class="text-center">操作</th>
				                                        {% endif %}														
				                                    </tr>
				                                </thead>
				                                <tbody>
				                                	{% for ds in projectList %}
				                                		<tr class="odd gradeX" id="deployLogs-{{ds.id}}">
				                                			<td class="text-center">{{ds.project.project.project_name}} </td>
				                                			<td class="text-center">{{ds.project_name}} </td>
				                                			<td class="text-center">
				                               					{% if ds.project.project_env == 'sit' %}
				                                					<span class="label label-success">测试环境</span>
				                                				{% elif ds.project.project_env == 'qa' %}
				                                					<span class="label label-warning">预生产环境</span>
				                                				{% elif ds.project.project_env == 'uat' %}
				                                					<span class="label label-danger">生产环境</span>
				                                				{% endif %}				                                			
				                                			</td>
				                                			<td class="text-center">
				                                			{% if ds.project_branch %}
				                                				<a href="javascript:;" target="_blank" class="tooltip-test" data-toggle="tooltip" title="{{ds.project_branch}}">{{ds.project_branch|slice:":13" }}...</a>		                                								                                			
				                                			{% endif %}
				                                			</td>
				                                			<td class="text-center">{{ds.project_content}} </td>
				                                			<td class="text-center">{{ds.project_user}} </td>				                                			
				                                			<td class="text-center">{{ds.create_time|date:"Y/m/d H:i  "}} </td>
				                                			{% if perms.OpsManage.delete_log_project_config %}
					                                			<td class="text-center">
					                                				<a href="javascript:" onclick="deleteDeployLogs(this,{{ds.id}})">
						                                				<button class="btn btn-danger btn-xs">					                                					
																			<i class="glyphicon glyphicon-trash  bigger-110 icon-only"></i>
																		</button>
																	</a>
																</td>
															{% endif %}				                                			
				                                		</tr>
				                                	{% endfor %}
				                                </tbody>
				                            </table>				       
										{% if projectList %}
											<ul class="pagination">
											        {% if projectList.has_previous %}
											            <li><a href="/deploy_log/{{ projectList.previous_page_number }}/">&laquo;</a></li>
											        {% endif %}
											        {% for page in projectList.paginator.page_range %}
											        	{% if projectList.number == page %}
											        		<li class="disabled"><a href="/deploy_log/{{page}}/">{{page}}</a></li>
											        	{% else %}
											        		<li><a href="/deploy_log/{{page}}/">{{page}}</a></li>
											        	{% endif %}
											        {% endfor %}
											        {% if projectList.has_next %}
											            <li><a href="/deploy_log/{{ projectList.next_page_number }}/">&raquo;</a></li>
											        {% endif %}
											</ul>
                     		            {% endif %}		
										</div>
				                   </div>
				              </div>				              
				           </div>


                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>    
</div>


<script type="text/javascript">


		$(document).ready(function() {
		    $('#projectTableList').DataTable({
		        responsive: true
		    });
		});

		function deleteDeployLogs(obj,id) {
			$.ajax({
				dataType: "JSON",
				url:'/api/logs/deploy/'+ id +'/', //请求地址
				type:"DELETE",  //提交类似
				success:function(response){
					var str= 'deployLogs-' + id
					document.getElementById(str).innerHTML = ''; 
				}					
			})					
		}				
  
</script>

{% endblock %}